<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class UH_Config extends CI_Config{

	public $def_img_arr = array(
	    'invite_img'       => './admin_web_img/default_invite.png',
	    'company_img'      => './admin_web_img/default_company.png',
	    'img'              => './admin_web_img/logo_web.png',
	    'pdf_thumb'        => './admin_web_img/default_pdf_thumb.jpg',
	    'company_thumb'    => './admin_web_img/default_company_thumb.png',
	    'product_thumb'    => './admin_web_img/default_product_thumb.png',
	    'equipment_thumb'  => './admin_web_img/default_equipment_thumb.png'
	);
	
	/**
	 * @获取模块地址
	 * */
	public function get_web_url($module = '')
	{
	    if (empty($module)) {
	        return $url = 'http://' . WBE_DOMAIN . '/';
	    }
	    if (WBE_DOMAIN==='uhelper.cn' && $module=='api') {
	        return $url = 'https://' . $module . '.' . WBE_DOMAIN . '/';
	    }
	    return $url = 'http://' . $module . '.' . WBE_DOMAIN. '/';
	}
	
	/**
	 * @param string $dirname：路径
	 * @param bool $is_dir：true/false 是否是目录
	 * @return string
	 * */
	public function upload_image_path($dirname='images', $is_dir=false)
	{
	    if (empty($dirname)) return false;
	    if ($is_dir) {
	        return dirname(FCPATH) . '/img.' . WBE_DOMAIN . '/' . $dirname . '/';
	    }
	    return dirname(FCPATH) . '/img.' . WBE_DOMAIN . '/' . $dirname;
	}
	
	/**
	 * @显示缩略图
	 * @param string $imageName 图片名称
	 */
	public function show_thumb_url($imageName)
	{
	    $img_arr = explode('.', $imageName);
	    $thumb = '.'.$img_arr[1].'_thumb.'.$img_arr[2];
	    if (file_exists($this->upload_image_path($thumb))) {
	        return $this->get_web_url('img').$thumb;
	    } else {
	        return $this->get_web_url('img').$this->def_img_arr['invite_img'];
	    }
	}
	
	
}